#include "NessTexture.h"

#include <iostream>
using namespace std;

NessTexture::NessTexture(){
}
NessTexture::~NessTexture(){
}

//texture loading
bool NessTexture::LoadTexture(const char *file){
	surface = IMG_Load(file);
	if(!surface)
		return false;
	
	glGenTextures(1, &texture);
	glBindTexture(GL_TEXTURE_2D, texture);

	if(surface->format->Amask==0)
		nOfColors=GL_RGB;
	else
		nOfColors=GL_RGBA;


	glTexImage2D(GL_TEXTURE_2D, 
		0, 
		nOfColors,
		surface->w,surface->h,
		0,
		nOfColors,
		GL_UNSIGNED_BYTE,
	surface->pixels);
	
	SDL_FreeSurface(surface);
	return true;
}

void NessTexture::DeleteTexture(){
	glDeleteTextures(1, &texture);
}